/**
 * @author：anlzou
 * @Date：Created in20:08 2021/3/27
 * @Github：https://github.com/anlzou
 * @Description：
 */
package com.anlzou.demo.controller;

import org.springframework.web.bind.annotation.*;

@RestController
public class ConExample01 {
    /*
    * @PathVariable注解
    * */
    @RequestMapping(value = "/path/1/{id}",method = RequestMethod.GET)
    public String demo01(@PathVariable("id") Integer id){
        return "id"+id;
    }

    /*
    * @RequestParam注解
    * 参数可以添加默认值
    * */
    @RequestMapping(value = "/path/2",method = RequestMethod.GET)
    public String demo02(@RequestParam("id") Integer id, @RequestParam("name") String name){
        return name+"："+id.toString();
    }

    /*
    * @GetMapping注解
    * */
    @GetMapping(value = "/path/3")
    public String demo03(@RequestParam(value = "id",required = false, defaultValue = "24") Integer id){
        return "id:"+id;
    }
}
